<template>
  <view class="cash-wallet">
	<view class="cash-wallet-top">
		<view class="cash-card">
			<view class="cash-card-tip">总资产(元)</view>
			<view class="cash-card-value">￥{{amount}}</view>
			<view class="cash-card-details" @click="customNav('/package_cash_wallet/pages/details')">收支明细</view>
			<view class="membership-code">
				<view class="code"></view>
				<text>会员码</text>
			</view>
		</view>
	</view>
	<view class="warm-tips">
		<text>温馨提示：</text>
		<text>现金余额不可提现</text>
		<text>充值有优惠，如需充值请联系管理员</text>
		<text @click="open" style="color: blue;">联系我们</text>
	</view>
	<up-popup :show="show" mode="center"  @close="close" @open="open">
	    <view>
	        <image @longpress="saveImg" class="contact-us" src="https://minio.gzryzl.com/huatai/2024-11-12/1731400478688contact-us.jpg"></image>
	    </view>
	</up-popup>
  </view>
</template>

<script setup>
import { ref } from "vue";
import { onLoad, onReachBottom, onShow } from "@dcloudio/uni-app";
import { customNav } from "../../utils/customNav";
import {getPurseInfoApi,gettbUserPurseLogsListApi} from "@/api/user/cashWallet.js"

const amount = ref('')

// 获取现金钱包
const getCashValue = ()=>{
	getPurseInfoApi().then(data=>{
		amount.value = data.data.amount.toFixed(2)
	})
}

// 长按保存
const saveImg = ()=>{
	uni.downloadFile({
	  url: 'https://minio.gzryzl.com/huatai/2024-11-12/1731400478688contact-us.jpg', // 图片的URL
	  success: async (res) => {
	    console.log(res);
	
	    if (res.statusCode === 200) {
	      uni.saveImageToPhotosAlbum({
	        filePath: res.tempFilePath, // 下载后的临时文件路径
	        success: () => {
	          console.log("保存成功");
	          uni.showToast({
	            icon: "none",
	            title: "保存成功",
	          });
	        },
	        fail: (error) => {
	          console.log("保存失败", error);
	        },
	      });
	    }
	  },
	  fail: (error) => {
	    console.log("下载失败", error);
	  },
	});
}

const show = ref(false);  

const open = ()=>{
	show.value=true
}

const close = ()=>{
	show.value=false
}

onLoad(() => {
  
})
onShow(() => {
	getCashValue();
});
</script>

<style lang="less" scoped>
@import url(../lib/index.less);
</style>